<?php
/**
 * @file
 * Default theme implementation for beans.
 *
 * Available variables:
 * - $content: An array of comment items. Use render($content) to print them all, or
 *   print a subset such as render($content['field_example']). Use
 *   hide($content['field_example']) to temporarily suppress the printing of a
 *   given element.
 * - $title: The (sanitized) entity label.
 * - $url: Direct url of the current entity if specified.
 * - $page: Flag for the full page state.
 * - $classes: String of classes that can be used to style contextually through
 *   CSS. It can be manipulated through the variable $classes_array from
 *   preprocess functions. By default the following classes are available, where
 *   the parts enclosed by {} are replaced by the appropriate values:
 *   - entity-{ENTITY_TYPE}
 *   - {ENTITY_TYPE}-{BUNDLE}
 *
 * Other variables:
 * - $classes_array: Array of html class attribute values. It is flattened
 *   into a string within the variable $classes.
 *
 * @see template_preprocess()
 * @see template_preprocess_entity()
 * @see template_process()
 */
?>

<?php
	//Find the right array with the correct fields
	$content = $elements['bean']['contact'];

	$company = render($content['field_company_name']);
	
	$email = render($content['field_company_emailcontact']);
	$email = strip_tags($email);
	$email = trim($email);
	
	$address = render($content['field_company_address']);
	
	$phone = render($content['field_company_phone']);
	$phone = strip_tags($phone);
	
	$maincontact = render($content['field_company_maincontact']);
	
	$mainemail = render($content['field_company_emailcontact']);
	$mainemail = strip_tags($mainemail);
	$mainemail = trim($mainemail);
	
	$edit_link = $elements['#block']->delta;
?>

<?php if($elements['#block']->region == "footer"):?>
<ul class="contact-info">
	<li class="contact"><a href="mailto:<?php print $email; ?>"><?php print t("Contact Us");?></a></li>
	<li class="address"><?php $address = strip_tags($address);print $address;?></li>
	<li class="phone">t: <?php print $phone;?> </li>
	<li>
<?php if (user_access('administer blocks')) :?>

<script type="text/javascript">
jQuery(document).ready(function ($){
  	
  	      $(".edit-menu").css({'opacity':'0.1'});
  	      $('.contact-block-info').hover(
    		function() {
        		$(this).find('.edit-menu').fadeTo(200, 0.9);
    		},
		    function() {
		        $(this).find('.edit-menu').fadeTo(200, 0.1);
		    }
			);
  	
	});

</script>
<li><a href='?q=block/<?php print $edit_link ?>/edit/'>Edit Contact Info</a></li>
<?php endif; ?>	
	</li>

</ul>
<?php endif;?>

<?php if($elements['#block']->region == "content"):?>
<div class="contact-block-info">
<?php if (user_access('administer blocks')) :?><div class="edit-menu"><a href='?q=block/<?php print $edit_link ?>/edit/'>Edit Contact Info</a></div><?php endif; ?>
<div class="contact-block">
	<h3><?php print $company;?></h3>
	<div class="address"><?php print $address;?></div>
	<div class="phone"><?php print $phone;?></div>
	<div class="info"></div>
</div>

<div class="contact-block">
	<h3><?php print $maincontact;?></h3>
	<div class="address"><?php print $address;?></div>
	<div class="phone"><a href="mailto:<?php print $mainemail;?>" target="_blank"><?php print $mainemail;?></a></div>
	<div class="info"></div>
</div>
</div>
<?php endif;?>

